﻿using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Transactions;
using Newtonsoft.Json;
using T.FAS.Runtime.Base.Entity;
using T.ServiceComponent.DAC.Service;
using System.Reflection;
using System.Data;

namespace T.FAS.Runtime.Base.Dao
{
    public class FASTenantConfigDao : DaoService<FASTenantConfig>
    {
        public override string TableName => "FAS_TenantConfig";
        public override string IDColumnName => "ID";
        public override List<string> ExceptColumnName => new List<string> { };


        public FASTenantConfigDao() : base()
        {
            DBName = "TFAS";
        }

        /// <summary>
        /// 从
        /// </summary>        
        /// <returns></returns>
        public List<FASTenantConfig> GetFASTenantConfig()
        {
            List<FASTenantConfig> list = new List<FASTenantConfig>();
            var ds = this.DB.ExecuteDataSet(string.Format("select ID, TenantID, TenantName, SGAddress, FTPAddress, ResourceAddress,EnableChangeSource, Creator, CreateTime, LastModifier, LastModifyTime from {0} ", TableName));
            if (ds != null && ds.Tables.Count>0 && ds.Tables[0].Rows.Count > 0)
            {
                foreach(DataRow dataRow in ds.Tables[0].Rows)
                {
                    var tenantConfig = this.ConvertToObject(this.Columns, dataRow);
                    list.Add(tenantConfig);
                }                
            }
            return list;
        }

        
    }
}
